package org.gc.contact.util;

import java.util.regex.Pattern;

public final class RegexpUtil {
	
	private static final String REGEXP_FORM_INPUT_VALUE = "<\\s*input(?:\\s+.*)*\\s+value=\"?([^\\s\"]*)\"?";
	private static final String REGEXP_HOST_FROM_URI = "http://([^/]+)/.*";
	private static final String REGEXP_JS_REDIRECTION = "location\\.replace\\(\"(.+)\"\\)";
	
	private static final Pattern PATTERN_FORM_INPUT_VALUE = Pattern.compile(REGEXP_FORM_INPUT_VALUE);
	private static final Pattern PATTERN_HOST_FROM_URI = Pattern.compile(REGEXP_HOST_FROM_URI);
	private static final Pattern PATTERN_JS_REDIRECTION = Pattern.compile(REGEXP_JS_REDIRECTION);
	
	
	private RegexpUtil() {}
	
	public static Pattern getFormInputValueRegexp() {
		return PATTERN_FORM_INPUT_VALUE;
	}
	
	public static Pattern getHostFromURIRegexp() {
		return PATTERN_HOST_FROM_URI;
	}
	
	public static Pattern getJSRedirectionRegexp() {
		return PATTERN_JS_REDIRECTION;
	}

}
